package cn.echoedu.command;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import cn.echoedu.command.base.ExecuteParam;
import cn.echoedu.command.base.FailureParam;
import cn.echoedu.command.base.SuccessParam;
import cn.echoedu.constants.Code;
import cn.echoedu.entity.SchoolNotify;
import cn.echoedu.entity.SchoolNotifyImage;
import cn.echoedu.util.DateUtil;

import com.google.gson.Gson;


public class SchoolNotifyDetailCommand extends BaseCommand {

	public void executeSuccess(SuccessParam successparam) {
		// TODO Auto-generated method stub
		List<SchoolNotifyImage> schoolnotifyimage = 
				(List<SchoolNotifyImage>)successparam.getParam();
		SchoolNotify schoolnotify = schoolnotifyimage.get(0).getSchoolnotify();
        SchoolNotifyDetailSuccess  schoolnotifydetailsuccess = 
        		new SchoolNotifyDetailSuccess();
        schoolnotifydetailsuccess.setCode(Code.SCHOOL_NOTIFY_LIST_DETAIL);
        schoolnotifydetailsuccess.setMsg("School Notify Detail Success");
        schoolnotifydetailsuccess.setSchoolnotifyid(schoolnotify.getSchoolnotifyid());
	    schoolnotifydetailsuccess.setTheme(schoolnotify.getTitle());
	    schoolnotifydetailsuccess.setPlace(schoolnotify.getPlace());
	    schoolnotifydetailsuccess.setContent(schoolnotify.getContent());
	    schoolnotifydetailsuccess.setFilepath(schoolnotify.getFilepath());
	    schoolnotifydetailsuccess.setStarttime(DateUtil.dateToString((Timestamp) schoolnotify.getStarttime()));
	    schoolnotifydetailsuccess.setEndtime(DateUtil.dateToString((Timestamp) schoolnotify.getEndtime()));
	    schoolnotifydetailsuccess.setAttion_time(DateUtil.dateToString((Timestamp) schoolnotify.getRemindertime()));
	    schoolnotifydetailsuccess.setHitcount(schoolnotify.getHitcount());
	    schoolnotifydetailsuccess.setTime(DateUtil.dateToString((Timestamp) schoolnotify.getPublishtime()));
	    schoolnotifydetailsuccess.setUser_number(schoolnotify.getTeacher().getTeachernumber());
	    schoolnotifydetailsuccess.setDepartmentcode(schoolnotify.getDepartment().getDepartmentcode());
	    schoolnotifydetailsuccess.setLikenum(schoolnotify.getLikenum());
	    schoolnotifydetailsuccess.setDislikenum(schoolnotify.getDislikenum());
	    List<PicUrl> pic_url_list = new ArrayList<PicUrl>();
	    for(SchoolNotifyImage notifyimage:schoolnotifyimage){
	    	PicUrl picurl = new PicUrl();
	     	picurl.setPic_url(notifyimage.getImage().getImagesrc());
	        pic_url_list.add(picurl);	
	    }
	    schoolnotifydetailsuccess.setPic_url_list(pic_url_list);
	    String result = new Gson().toJson(schoolnotifydetailsuccess);
	    send(result,successparam.getResponse());
	
	}

	public void executeFailure(FailureParam failureparam) {
		// TODO Auto-generated method stub

	}

	public void execute(ExecuteParam executeparam) {
		// TODO Auto-generated method stub

	}
	class SchoolNotifyDetailSuccess{
		private int code;
		private String msg;
		private int schoolnotifyid;
		private String theme;
		private String place;
		private String content;
		private String filepath;
		private String starttime;
		private String endtime;
		private String attion_time;
		private int hitcount;
		private String time;
		private String user_number;
		private int departmentcode;
		private int likenum;
		private int dislikenum;
		private List<PicUrl> pic_url_list;
		public int getCode() {
			return code;
		}
		public void setCode(int code) {
			this.code = code;
		}
		public String getMsg() {
			return msg;
		}
		public void setMsg(String msg) {
			this.msg = msg;
		}
		public int getSchoolnotifyid() {
			return schoolnotifyid;
		}
		public void setSchoolnotifyid(int schoolnotifyid) {
			this.schoolnotifyid = schoolnotifyid;
		}
		public String getTheme() {
			return theme;
		}
		public void setTheme(String theme) {
			this.theme = theme;
		}
		public String getPlace() {
			return place;
		}
		public void setPlace(String place) {
			this.place = place;
		}
		public String getContent() {
			return content;
		}
		public void setContent(String content) {
			this.content = content;
		}
		public String getFilepath() {
			return filepath;
		}
		public void setFilepath(String filepath) {
			this.filepath = filepath;
		}
		public String getStarttime() {
			return starttime;
		}
		public void setStarttime(String starttime) {
			this.starttime = starttime;
		}
		public String getEndtime() {
			return endtime;
		}
		public void setEndtime(String endtime) {
			this.endtime = endtime;
		}
		public String getAttion_time() {
			return attion_time;
		}
		public void setAttion_time(String attion_time) {
			this.attion_time = attion_time;
		}
		public int getHitcount() {
			return hitcount;
		}
		public void setHitcount(int hitcount) {
			this.hitcount = hitcount;
		}
		public String getTime() {
			return time;
		}
		public void setTime(String time) {
			this.time = time;
		}
		
		public String getUser_number() {
			return user_number;
		}
		public void setUser_number(String user_number) {
			this.user_number = user_number;
		}
		public int getDepartmentcode() {
			return departmentcode;
		}
		public void setDepartmentcode(int departmentcode) {
			this.departmentcode = departmentcode;
		}
		public int getLikenum() {
			return likenum;
		}
		public void setLikenum(int likenum) {
			this.likenum = likenum;
		}
		public int getDislikenum() {
			return dislikenum;
		}
		public void setDislikenum(int dislikenum) {
			this.dislikenum = dislikenum;
		}
		public List<PicUrl> getPic_url_list() {
			return pic_url_list;
		}
		public void setPic_url_list(List<PicUrl> pic_url_list) {
			this.pic_url_list = pic_url_list;
		}
		
	}
	class PicUrl{
		private String pic_url;

		public String getPic_url() {
			return pic_url;
		}

		public void setPic_url(String pic_url) {
			this.pic_url = pic_url;
		}
		
	}

}
